<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_sys_class('model', '', 0);


class contest_source_model extends model
{

    public function __construct()
    {
        $this->db_config = pc_base::load_config('database');
        $this->db_setting = 'default';
        $this->table_name = 'contest_source';
        parent::__construct();
    }

    /**
     * 图片删除
     */
    public function edit ($source_id, $contest_id, $source_type) {
    	$data = array();
    	$data['created_by'] =  $_SESSION['userid'];
        $data['updated_by'] =  $_SESSION['userid'];

        $data['create_time'] = date('Y-m-d H:i:s');
        $data['update_time'] = date('Y-m-d H:i:s');
        $data['source_type'] = $source_type;
        $data['source_id'] = $source_id;
        $data['contest_id'] = $contest_id;
        $this->insert($data);
    }

    /**
     * 删除绑定关系
     */
    public function deleteBind ($id, $source_type) {

        $where = ' source_id = ' . $id;
        
        if ($source_type) {
            $where .= ' and source_type = ' . $source_type;
        }
        
        //执行删除操作
        $this->delete($where);
    }

}